import service from "@/utils/request";

/**
 * 获取竞赛列表
 * @param {Object} params
 * @returns
 */
export function getexamListService(params) {
  return service({
    url: "/exam/list",
    method: "get",
    params,
  });
}

/**
 * 添加竞赛
 * @param {Object} data
 * @returns
 */
export function addexamService(data = {}) {
  return service({
    url: "/exam/add",
    method: "post",
    data,
  });
}

/**
 * 编辑竞赛
 * @param {Object} data
 * @returns
 */
export function editexamService(data = {}) {
  return service({
    url: "/exam/edit",
    method: "put",
    data,
  });
}

/**
 * 删除竞赛
 * @param {number} examId
 * @returns
 */
export function deleteExamService(examId) {
  return service({
    url: "/exam/delete",
    method: "delete",
    params: { examId },
  });
}

/**
 * 获取竞赛详情
 * @param {number} examId
 * @returns
 */
export function getexamDetailService(examId) {
  return service({
    url: "/exam/detail",
    method: "get",
    params: { examId },
  });
}

/**
 * 添加竞赛题目
 * @param {Object} data
 * @returns
 */
export function addExamQuestionService(data = {}) {
  return service({
    url: "/exam/question/add",
    method: "post",
    data,
  });
}

/**
 * 删除竞赛题目
 * @param {number} examId
 * @param {number} questionId
 * @returns
 */
export function delExamQuestionService(examId, questionId) {
  return service({
    url: "/exam/question/delete",
    method: "delete",
    params: { examId, questionId },
  });
}

/**
 * 发布竞赛
 * @param {number} examId
 * @returns
 */
export function publishExamService(examId) {
  return service({
    url: "/exam/publish",
    method: "put",
    params: { examId },
  });
}

export function cancelPublishExamService(examId) {
  return service({
    url: "/exam/cancelPublish",
    method: "put",
    params: { examId },
  });
}
